{$CLEO .cs}
// : " "
// : 1.0 [ 2014]
// : kenking 
// E-mail: kenking@rambler.ru
const
  AVTO = 0@           // 
  MODEL_AVTO = 1@     //  
  DRIVER_AVTO = 2@    // 
  MODEL_DRIVER = 3@   //  
  PED_TYPE = 4@       //  
  ESCORT = 5@         //  
  DRIVER_ESCORT = 6@  //   
  COUNTER = 14@       // 
end

COUNTER = 1

while true
wait 0
    if
      Player.Defined($PLAYER_CHAR)
    then
        if
          $ONMISSION == 0
        then
            if  
              COUNTER == 1
            then
                MODEL_AVTO = 146 // ambulan
                MODEL_DRIVER = 5 // medic
                PED_TYPE = 16    // EMERGENCY
            else
                if
                  COUNTER == 2
                then
                    MODEL_AVTO = 137 // firetruk
                    MODEL_DRIVER = 6 // fireman
                    PED_TYPE = 17    // FIREMAN
                else
                    if
                      COUNTER == 3
                    then
                        MODEL_AVTO = 158  // securica
                        MODEL_DRIVER = 91 // GDa
                        PED_TYPE = 4     // COP
                    else
                        if
                          COUNTER == 4
                        then  
                            MODEL_AVTO = 172 // romero
                            MODEL_DRIVER = 5 // medic
                            PED_TYPE = 16    // EMERGENCY
                                                       
                        end    
                    end    
                end    
            end  
            04C4: store_coords_to 10@ 11@ 16@ from_actor $PLAYER_ACTOR with_offset 50.0 150.0 0.0
            04C4: store_coords_to 12@ 13@ 16@ from_actor $PLAYER_ACTOR with_offset -50.0 70.0 0.0 
            053E: 15@ = get_random_car_with_actors -1 in_area 10@ 11@ 12@ 13@ 
            if
              15@ <> -1
            then  
                0407: create_coordinate 10@ 11@ 12@ from_car 15@ offset 0.0 0.0 0.0 
                0174: 13@ = car 15@ z_angle 
                repeat
                   if
                     00EC: actor $PLAYER_ACTOR sphere 0 near_point 10@ 11@ radius 200.0 200.0
                   jf break
                   wait 0
                until 838A: not car_in_cube 10@ 11@ 12@ 5.0 7.0 3.0
                if                
                  80EC: not actor $PLAYER_ACTOR sphere 0 near_point 10@ 11@ radius 50.0 50.0
                then
                    Model.Load(MODEL_AVTO) //    
                    Model.Load(MODEL_DRIVER) //    
                    038B: load_requested_models //   
                    if and
                      Model.Available(MODEL_AVTO)
                      Model.Available(MODEL_DRIVER)
                    then  
                        12@ -= 1.0
                        AVTO = Car.Create(MODEL_AVTO, 10@, 11@, 12@)
                        0175: set_car AVTO z_angle_to 13@ 
                        0129: DRIVER_AVTO = create_actor_pedtype PED_TYPE model MODEL_DRIVER in_car AVTO driverseat
                        if
                          MODEL_AVTO == 158 // securica
                        then  
                            020A: set_car AVTO door_status_to 2
                            02AC: set_car AVTO immunities 1 1 1 1 1 
                            053F: set_car AVTO tires_vulnerable 0 
                        else
                            020A: set_car AVTO door_status_to 1
                        end    
                        Model.Destroy(MODEL_AVTO) //   
                        Model.Destroy(MODEL_DRIVER) //   
                        0208: 15@ = random_float_in_ranges 15.0 35.0
                        Car.SetMaxSpeed(AVTO, 15@)
                        
                        00AF: set_car AVTO driver_behaviour_to 11 
                        //Car.SetDriverBehaviour(AVTO, 11)
                        if and
                          15@ > 25.0 
                          MODEL_AVTO <> 172 // romero
                          MODEL_AVTO <> 158 // securica
                        then  
                            if and
                              MODEL_AVTO <> 163 // barracks
                              MODEL_AVTO <> 200 // patriot
                            then  
                                0397: enable_car AVTO siren 1
                            end    
                            00AE: set_car AVTO traffic_behaviour_to 2
                            //  
                            0209: 9@ = random_int 0 5
                            if or
                              9@ == 1
                              9@ == 2
                              9@ == 4
                            then
                                if  
                                  COUNTER == 1
                                then
                                    MODEL_AVTO = 137 // firetruk
                                    MODEL_DRIVER = 6 // fireman
                                    PED_TYPE = 17    // FIREMAN
                                else
                                    if
                                      COUNTER == 2
                                    then
                                        MODEL_AVTO = 146 // ambulan
                                        MODEL_DRIVER = 5 // medic
                                        PED_TYPE = 16    // EMERGENCY
                                       
                                    end    
                                end  
                                0407: create_coordinate 10@ 11@ 12@ from_car AVTO offset 0.0 -16.0 0.0
                                if
                                  838A: not car_in_cube 10@ 11@ 12@ 5.0 6.0 3.0
                                then  
                                    Model.Load(MODEL_AVTO) 
                                    Model.Load(MODEL_DRIVER) 
                                    038B: load_requested_models 
                                    if and
                                      Model.Available(MODEL_AVTO)
                                      Model.Available(MODEL_DRIVER)
                                    then  
                                        12@ -= 1.0
                                        ESCORT = Car.Create(MODEL_AVTO, 10@, 11@, 12@)
                                        0175: set_car ESCORT z_angle_to 13@ 
                                        020A: set_car ESCORT door_status_to 1
                                        0129: DRIVER_ESCORT = create_actor_pedtype PED_TYPE model MODEL_DRIVER in_car ESCORT driverseat
                                        if and
                                          MODEL_AVTO <> 163 // barracks
                                          MODEL_AVTO <> 200 // patriot
                                        then  
                                            0397: enable_car ESCORT siren 1
                                        end    
                                        00AE: set_car ESCORT traffic_behaviour_to 2
                                        04BD: set_car ESCORT is_part_of_convoy 1
                                        Car.SetMaxSpeed(ESCORT, 15@)  
                                        00AF: set_car ESCORT driver_behaviour_to 11 
                                        //Car.SetDriverBehaviour(ESCORT, 11)
                                        Model.Destroy(MODEL_AVTO) 
                                        Model.Destroy(MODEL_DRIVER)
                                    end    
                                end    
                            end
                        else
                            00AE: set_car AVTO traffic_behaviour_to 4
                        end
                        if
                          COUNTER < 5
                        then
                            COUNTER += 1
                        else
                            COUNTER = 1
                        end   
                        Actor.RemoveReferences(DRIVER_AVTO)
                        Actor.RemoveReferences(DRIVER_ESCORT)
                        Car.RemoveReferences(AVTO)
                        Car.RemoveReferences(ESCORT)
                        00BF: 7@ = current_time_hours, 8@ = current_time_minutes 
                        if and
                          7@ >= 6
                          7@ < 23
                        then  
                            wait 30000 //   
                        else
                            wait 60000 //   
                        end    
                    end    
                end
            end           
        end  
    end
end    